package com.team.ssm_item_lj.service.impl;

import com.team.ssm_item_lj.entity.JavaeeTeam;
import com.team.ssm_item_lj.dao.JavaeeTeamDao;
import com.team.ssm_item_lj.service.JavaeeTeamService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import jakarta.annotation.Resource;

import java.util.List;

/**
 * 开发团队表(JavaeeTeam)表服务实现类
 *
 * @author zhuxhenxin
 * @since 2024-12-05 10:44:29
 */
@Service("javaeeTeamService")
public class JavaeeTeamServiceImpl implements JavaeeTeamService {
    @Resource
    private JavaeeTeamDao javaeeTeamDao;

    /**
     * 通过ID查询单条数据
     *
     * @param teamId 主键
     * @return 实例对象
     */
    @Override
    public JavaeeTeam queryById(Long teamId) {
        return this.javaeeTeamDao.queryById(teamId);
    }

    /**
     * 分页查询
     *
     * @param javaeeTeam 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JavaeeTeam> queryByPage(JavaeeTeam javaeeTeam, PageRequest pageRequest) {
        long total = this.javaeeTeamDao.count(javaeeTeam);
        return new PageImpl<>(this.javaeeTeamDao.queryAllByLimit(javaeeTeam, pageRequest), pageRequest, total);
    }

    /**
     * 新增数据
     *
     * @param javaeeTeam 实例对象
     * @return 实例对象
     */
    @Override
    public JavaeeTeam insert(JavaeeTeam javaeeTeam) {
        this.javaeeTeamDao.insert(javaeeTeam);
        return javaeeTeam;
    }

    /**
     * 修改数据
     *
     * @param javaeeTeam 实例对象
     * @return 实例对象
     */
    @Override
    public JavaeeTeam update(JavaeeTeam javaeeTeam) {
        this.javaeeTeamDao.update(javaeeTeam);
        return this.queryById(javaeeTeam.getTeamId());
    }

    /**
     * 通过主键删除数据
     *
     * @param teamId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long teamId) {
        return this.javaeeTeamDao.deleteById(teamId) > 0;
    }

    /**
     * 查询所有数据
     *
     * @return
     */
    @Override
    public List<JavaeeTeam> queryAll() {
        return javaeeTeamDao.queryAll();
    }

    /**
     * 根据JavaeeTeam查询数据
     *
     * @param javaeeTeam
     * @return
     */
    @Override
    public List<JavaeeTeam> queryByJavaeeTeam(JavaeeTeam javaeeTeam) {
        return javaeeTeamDao.queryByJavaeeTeam(javaeeTeam);
    }


}
